import { defineConfig, loadEnv } from "vite";
import path from "path";
import uni from "@dcloudio/vite-plugin-uni";
import appUrl from "./src/appConfig.json"
// https://vitejs.dev/config/
export default defineConfig({
	resolve: {
		alias: {
			"@": path.resolve(__dirname, "src"),
			"components": path.resolve(__dirname, "src/components"),
			"apis": path.resolve(__dirname, "src/apis"),
			"fun": path.resolve(__dirname, "src/common/func"),
			"hooks": path.resolve(__dirname, "src/hooks"),

		},
	},
	plugins: [uni()],

	server: {
		port: 3000,
		proxy: {
			'/api': {
				target: appUrl.urls['development'], // 目标服务  
				changeOrigin: true,
				rewrite: path => path.replace(/^\/api/, ''),
			},
			'/testApi': {
				target: appUrl.urls['test'], // 目标服务  
				changeOrigin: true,
				rewrite: path => path.replace(/^\/testApi/, ''),
			}
		}
	}
});
